<!-- 资料收集 -->
import func from './vue-temp/vue-editor-bridge';
<template>
  <div>
    <Card :bordered="false">
      <p slot="title">
        <Row>
          <Col span="12" style="line-height:32px !important"> 资料收集
          </Col>
          <Col span="12" style="text-align: right">
          <a target="_blank" href="http://xgs.letqvc.cn/home/PublicEditor">
            <Button type="primary">公示</Button>
          </a>
          </Col>
        </Row>
      </p>
      <Form ref="form" :model="info" :rules="rules">
        <FormItem>
          <table id="dataCollection" ref="print" width='100%' border="1" cellspacing="0" cellpadding="0">
            <tr>
              <th colspan="4">
                项目基本信息表
              </th>
            </tr>
            <tr>
              <td width="25%">
                项目编号
              </td>
              <td colspan="3">
                {{info.Project_number}}
              </td>
            </tr>
            <tr>
              <td width="25%">
                <Icon type="ios-medical" color="#ff6868" /> 项目名称
              </td>
              <td colspan="3">
                <FormItem prop="Project_name">
                  <Input v-model="info.Project_name" />
                </FormItem>
              </td>
            </tr>
            <tr>
              <td width="25%">
                <Icon type="ios-medical" color="#ff6868" /> 建设单位
              </td>
              <td colspan="3">
                <FormItem prop="Build_unit">
                  <Input v-model="info.Build_unit" />
                </FormItem>
              </td>
            </tr>
            <tr>
              <td width="25%">
                法　　人
              </td>
              <td>
                <Input v-model="info.Legal_person" />
              </td>
              <td width="25%">
                <Icon type="ios-medical" color="#ff6868" /> 联系人
              </td>
              <td>
                <FormItem prop="Linkman">
                  <Input v-model="info.Linkman" />
                </FormItem>
              </td>
            </tr>
            <tr>
              <td width="25%">
                通讯地址
              </td>
              <td colspan="3">
                <Input v-model="info.Mail_address" />
              </td>
            </tr>
            <tr>
              <td width="25%">
                <Icon type="ios-medical" color="#ff6868" /> 联系电话
              </td>
              <td>
                <FormItem prop="Tel_number">
                  <Input v-model="info.Tel_number" />
                </FormItem>
              </td>
              <td width="25%">
                邮政编码
              </td>
              <td>
                <Input v-model="info.Mail_zip_code" />
              </td>
            </tr>
            <tr>
              <td width="25%">

                <Icon type="ios-medical" color="#ff6868" /> 建设地点
              </td>
              <td colspan="3">
                <FormItem prop="Build_address">
                  <Input v-model="info.Build_address" />
                </FormItem>
              </td>
            </tr>
            <tr>
              <td width="25%">
                建设性质
              </td>
              <td>
                <RadioGroup v-model="info.Bulid_property">
                  <Radio label="新建">
                    <span>新建</span>
                  </Radio>
                  <Radio label="改建">
                    <span>改建</span>
                  </Radio>
                  <Radio label="扩建">
                    <span>扩建</span>
                  </Radio>
                </RadioGroup>
              </td>
              <td width="25%">
                国民经济行业类型
              </td>
              <td>
                示例：031 牧畜饲养
                <Select v-model="info.Economy_industry_type" placeholder="国民行业分类" size="small">
                  <Option value="beijing">New York</Option>
                  <Option value="shanghai">London</Option>
                </Select>
              </td>
            </tr>
            <tr>
              <td width="25%">
                立项审批部门
              </td>
              <td>
              </td>
              <td width="25%">
                项目代码
              </td>
              <td>
                <Input v-model="info.Project_code" />
              </td>
            </tr>
            <tr>
              <td width="25%">
                占地面积（平方米）
              </td>
              <td>
                <Input v-model="info.Floor_space" />
              </td>
              <td width="25%">
                绿化面积（平方米）
              </td>
              <td>
                <Input v-model="info.Green_space" />
              </td>
            </tr>
            <tr>
              <td width="25%">
                总投资（万元）
              </td>
              <td>
                <Input v-model="info.Total_investment" />
              </td>
              <td width="25%">
                环评合同额（万元）
              </td>
              <td>
                <Input v-model="info.Contract_amount" />
              </td>
            </tr>
            <tr>
              <td width="25%">
                <Icon type="ios-medical" color="#ff6868" /> 报告类型
              </td>
              <td style="text-align:left">
                示例：031 牧畜饲养
                <FormItem prop="Report_type">
                  <Cascader :data="getReportAlldata" change-on-select @on-change="getId">
                  </Cascader>
                </FormItem>
              </td>
              <td width="25%">
                <Icon type="ios-medical" color="#ff6868" /> 环评分类管理名录
              </td>
              <td style="text-align:left">
                示例：2 粮食及饲料加工
                <FormItem prop="Eia_assess_category">
                  <Select v-model="info.Eia_assess_category" style="width:100px" size="small">

                  </Select>
                </FormItem>
              </td>

            </tr>
            <tr>
              <td width="25%">
                产业政策
              </td>
              <td>
                <RadioGroup v-model="info.Industrial_policy">
                  <Radio label="鼓励类">
                    <span>鼓励类</span>
                  </Radio>
                  <Radio label="淘汰类">
                    <span>淘汰类</span>
                  </Radio>
                  <Radio label="限制类">
                    <span>限制类</span>
                  </Radio>
                  <Radio label="允许类">
                    <span>允许类</span>
                  </Radio>
                </RadioGroup>
              </td>
              <td width="25%">
                行业准入
              </td>
              <td>
                <RadioGroup v-model="info.Industry_access">
                  <Radio label="符合">
                    <span>符合</span>
                  </Radio>
                  <Radio label="不符合">
                    <span>不符合</span>
                  </Radio>
                </RadioGroup>
              </td>
            </tr>
            <tr>
              <td width="25%">
                分级审批
              </td>
              <td>
                <RadioGroup v-model="info.Grade_approval">
                  <Radio label="部批">
                    <span>部批</span>
                  </Radio>
                  <Radio label="省批">
                    <span>省批</span>
                  </Radio>
                  <Radio label="市批">
                    <span>市批</span>
                  </Radio>
                  <Radio label="县批（区批）">
                    <span>县批（区批）</span>
                  </Radio>
                </RadioGroup>
              </td>
              <td width="25%">
                审批部门
              </td>
              <td>
                <Input v-model="info.Approval_unit" />
              </td>
            </tr>
            <tr>
              <td width="25%">
                项目合同
              </td>
              <td>
                <UploadFile v-model="info.Project_trust_instrument" />
              </td>
              <td width="25%">
                项目委托书
              </td>
              <td>
                <UploadFile v-model="info.Project_trust_instrument" />
              </td>
            </tr>
            <tr>
              <td width="25%">
                原环评报告
              </td>
              <td>
                <UploadFile v-model="info.Org_eia_report" />
              </td>
              <td width="25%">
                原环评批复
              </td>
              <td>
                <UploadFile v-model="info.Org_eia_reply" />
              </td>
            </tr>
            <tr>
              <td width="25%">
                原项目验收文件
              </td>
              <td>
                <UploadFile v-model="info.Org_project_acceptance_doc" />
              </td>
              <td width="25%">
                原项目实际监测文件
              </td>
              <td>
                <UploadFile v-model="info.Org_project_monitoring_doc" />
              </td>
            </tr>
            <tr>
              <td width="25%">
                厂区现有平面图
              </td>
              <td>
                <UploadFile v-model="info.Factory_flat_map" />
              </td>
              <td width="25%">
                厂区现有环保设施情况
              </td>
              <td style="text-align:left">
                废水：<Input v-model="info.Existing_waste_water" />
                <br> 废气：<Input v-model="info.Existing_exhaust_gas" size="small" />
                <br> 噪声：<Input v-model="info.Existing_noise" size="small" />
                <br> 固废：<Input v-model="info.Existing_solid_waste" size="small" />
              </td>
            </tr>
            <tr>
              <td width="25%">
                土地文件
              </td>
              <td>
                <UploadFile v-model="info.Land_doc" />
              </td>
              <td width="25%">
                <Icon type="ios-medical" color="#ff6868" />土地相符性
              </td>
              <td>
                <FormItem prop="Land_conformity">
                  <RadioGroup v-model="info.Land_conformity">
                    <Radio label="符合">
                      <span>符合</span>
                    </Radio>
                    <Radio label="不符合">
                      <span>不符合</span>
                    </Radio>
                  </RadioGroup>
                </FormItem>
              </td>
            </tr>
            <tr>
              <td width="25%">
                规划文件
              </td>
              <td>
                <UploadFile v-model="info.Planning_doc" />
              </td>
              <td width="25%">
                <Icon type="ios-medical" color="#ff6868" />规划相符性
              </td>
              <td>
                <FormItem prop="Planning_conformity">
                  <RadioGroup v-model="info.Planning_conformity">
                    <Radio label="符合">
                      <span>符合</span>
                    </Radio>
                    <Radio label="不符合">
                      <span>不符合</span>
                    </Radio>
                  </RadioGroup>
                </FormItem>
              </td>
            </tr>
            <tr>
              <td width="25%">
                立项文件
              </td>
              <td>
                <UploadFile v-model="info.Create_project_doc" UploadFileName="Create_project_doc" :UploadFileId="$route.query.Project_id" />
              </td>
              <td width="25%">
                可研/项目建议书
              </td>
              <td>
                <UploadFile v-model="info.Project_proposal" />
              </td>
            </tr>
            <tr>
              <td width="25%">
                项目平面图
              </td>
              <td>
                <UploadFile v-model="info.Project_flat_map" />
              </td>
              <td width="25%">
                其他资料
              </td>
              <td>
                <UploadFile v-model="info.Project_other_doc" />
              </td>
            </tr>
          </table>
        </FormItem>
        </td>
        </tr>
        </table>
        </FormItem>
      </Form>
      <table width='100%' border="1" cellspacing="0" cellpadding="0" style="margin-top:10px ">
        <tr>
          <th>
            本项目组成员
          </th>
        </tr>
        <tr>
          <td>
            <div style="width:99%;margin:auto ">
              <Table id="xmcyz" v-if="flag" border :columns="dataAllBookOption" :data="dataAllBook"></Table>
            </div>
          </td>
        </tr>
        <tr>
          <td>
            <!-- 添加一行 -->
            <Button type="primary">添加</Button>
            <Button type="error">删除</Button>
            </Button>
          </td>
        </tr>
      </table>
      <Row style="padding:20px 0">
        <Col span="12" style="text-align: left">
        <PrintButton v-if="flag" Url="print/printCollect" :Project_id="info.Id"></PrintButton>
        </Col>
        <Col span="12" style="text-align: right">
        <Button type="primary" @click="submit('save')">
          保存
        </Button>
        <Button type="primary" @click="submit('submit')">
          提交
        </Button>
        </Col>
      </Row>
      <StepBar :status="1" />
    </Card>
    <Modal v-model="modal1" title="报告类型" @on-ok="ok" @on-cancel="cancel">
      <p>
        <table width='100%' border="1" cellspacing="0" cellpadding="0">
          <tr>
            <td rowspan="11">
              报告表
            </td>
            <td width="60" rowspan="8">
              一般报告表
            </td>
            <td>
              无专项
            </td>
            <td>
              <Checkbox label="twitter">
              </Checkbox>
            </td>
            <td rowspan="11">
              报告书
            </td>
            <td>
              轻工纺织化纤物
            </td>
            <td>
              <Checkbox label="twitter">
              </Checkbox>
            </td>
          </tr>
          <tr>
            <td>
              地表水环境影响专项
            </td>
            <td>
              <Checkbox label="twitter">
              </Checkbox>
            </td>
            <td>
              化工石化医药
            </td>
            <td>
              <Checkbox label="twitter">
              </Checkbox>
            </td>
          </tr>
          <tr>
            <td>
              地下水环境影响专项
            </td>
            <td>
              <Checkbox label="twitter">
              </Checkbox>
            </td>
            <td>
              冶金机电
            </td>
            <td>
              <Checkbox label="twitter">
              </Checkbox>
            </td>
          </tr>
          <tr>
            <td>
              环境风险专项
            </td>
            <td>
              <Checkbox label="twitter">
              </Checkbox>
            </td>
            <td>
              建材火电
            </td>
            <td>
              <Checkbox label="twitter">
              </Checkbox>
            </td>
          </tr>
          <tr>
            <td>
              大气环境影响专项
            </td>
            <td>
            </td>
            <td>
              农林水利
            </td>
            <td>
            </td>
          </tr>
          <tr>
            <td>
              声环境影响专项
            </td>
            <td>
            </td>
            <td>
              采掘
            </td>
            <td>
            </td>
          </tr>
          <tr>
            <td>
              工程分析环境影响专项
            </td>
            <td>
            </td>
            <td>
              交通运输
            </td>
            <td>
            </td>
          </tr>
          <tr>
            <td>
              污染防治措施专项
            </td>
            <td>
            </td>
            <td>
              社会服务
            </td>
            <td>
            </td>
          </tr>
          <tr>
            <td rowspan="3">
              核与辐 射项目 报告表
            </td>
            <td>
              无专项
            </td>
            <td>
            </td>
            <td>
              海洋工程
            </td>
            <td>
            </td>
          </tr>
          <tr>
            <td rowspan="2">
              辐射专项
            </td>
            <td>
            </td>
            <td>
              输变电及广电通讯
            </td>
            <td>
            </td>
          </tr>
          <tr>
            <td>
            </td>
            <td>
              核工业
            </td>
            <td>
            </td>
          </tr>
        </table>
      </p>
    </Modal>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        flag: false,
        upload_url: '',
        projectUplod: {
          fileIDs: '',
          xmht: []
        },
        loadingStatus: false,
        //项目合同
        Project_contract: null,
        //调用接口
        bookfirstId: "",
        //发送id
        booklastId: "",
        info: {},
        getReportAlldataVal: [],
        getReportAlldata: [],
        rules: {
          Project_name: {
            required: true,
            trigger: 'blur',
            message: '项目名称不能为空',
          },
          Linkman: {
            required: true,
            trigger: 'blur',
            message: '联系人不能为空',
          },
          Build_unit: {
            required: true,
            trigger: 'blur',
            message: '建设单位不能为空',
          },
          Legal_person: {
            required: true,
            trigger: 'blur',
            message: '法人不能为空',
          },
          Tel_number: {
            required: true,
            trigger: 'blur',
            message: '联系电话不能为空',
          },
          Build_address: {
            required: true,
            trigger: 'blur',
            message: '建设地址不能为空',
          },
          Eia_assess_category: {
            required: true,
            trigger: 'change',
            message: '管理目录不能为空',
          },
          Report_type: {
            required: true,
            trigger: 'change',
            message: '报告类型不能为空',
          },
          Land_conformity: {
            required: true,
            trigger: 'change',
            message: '相符性不能为空',
          },
          Planning_conformity: {
            required: true,
            trigger: 'change',
            message: '规划性不能为空',
          },

        },
        reportChapter: [],
        modal1: false,
        model1: "",
        dataAllBook: [],
        dataAllBookOption: [{
            type: "index",
            title: "序号",
            width: 80,
            align: "center",
            key: "num"
          },
          {
            title: "项目组成员",
            key: "name"
          },
          {
            title: "选择",
            key: 'reportChapter',
            render: (h, params) => {
              return h("Select", {
                  props: {
                    value: this.dataAllBook[params.index].reportChapter
                  },
                  on: {
                    'on-change': (value) => {
                      let ReportChapter = value
                      let id = this.dataAllBook[params.index].id
                      axios.post('/audit/updateStaffs', {
                        id,
                        ReportChapter
                      }).then(res => {
                        console.log(res)
                      })
                    }
                  },
                },
                this.dataAllBook[params.index].reportChapter.map(function (e) {
                  return h('Option', {
                    props: {
                      value: e.chapter
                    }
                  }, e.chapter);
                })
              )
            },
          }
        ]
      };
    },
    created() {
      this.upload_url = "http://39.105.60.116:8080/eao/upload.dox"
      //判断是否有ID
      if (this.$route.query.Project_id && this.$route.query.Project_id != '') {
        this.getProject(this.$route.query.Project_id)
        this.getReport()
      } else {
        //跳转首页
        this.$router.push({
          name: "index"
        })
      }
    },
    methods: {
      // 上传合同
      uploadSuccess(res, file) { // 文件上传回调 上传成功后删除待上传文件
        let that = this;
        if (res._STATUS == 1) {
          that.projectUplod.fileIDs += res.FileID + ',';
        } else {
          that.$Message.error(res.Message);
        }
      },
      /* 选中后获取到id 调用下个接口 */
      getId(value, selectedData) {
        let val = value
        console.log(val)
        if (value.length > 1) {
          console.log('多层');
          this.bookfirstId = val[0]
          this.booklastId = val.pop()
          this.info.Report_special_item = this.booklastId
          this.findByBookOrBook(this.bookfirstId)
        } else {
          console.log('单层');
          this.bookfirstId = val.join('')
          this.info.Report_special_item = this.bookfirstId
          this.booklastId = val.join('')
          //调取项目成员组
          this.findByBookOrBook(this.bookfirstId)
        }
      },
      findByBookOrBook(id) {
        console.log(id + ' 获取的项目id')
        axios.post('/audit/findByStaffs', {
          Project_id: this.$route.query.Project_id,
          Report_type: id
        }).then(res => {
          this.dataAllBook = res.projectStaff
          console.log(res.projectStaff[0])
        })
      },
      getReport() {
        axios.get('/reportType/findAllMenu').then(res => {
          if (res._STATUS == 1) {
            this.getReportAlldata = res.data
          }
        }).catch(err => {
          alert('请求失败')
        })
      },
      ok() {
        this.$Message.info("Clicked ok");
      },
      cancel() {
        this.$Message.info("Clicked cancel");
      },

      /* 获取当前创建项目 */
      getProject(id) {
        axios.get('/projectInformation/findProjectByID', {
          params: {
            id
          }
        }).then(res => {
          this.info = res.info
          localStorage.projectType = this.info.Perject_type
          this.flag = true
        }).catch(err => {
          alert('请求崩溃1231')
        })
      },
      // 保存 save / 提交 submit
      submit(type) {
        // 验证
        this.$refs.form.validate((valid) => {
          if (!valid) {
            // return
          }
          let info = this.info
          info.btn_way = type == 'save' ? 1 : 2
          info.Perject_type = type == 'save' ? 2 : 2
          axios.post('/projectInformation/saveOrUpdateProject', info).then((res) => {
            if (res._STATUS == 1) {
              let title = res._MESSAGE
              if (type == 'save') {
                this.$Modal.success({
                  title,
                })
              } else {
                this.$router.push({
                  name: "reconnaissanceTrip",
                  query: {
                    Project_id: this.$route.query.Project_id,
                  }
                })
              }
            } else {
              // 提示
              this.$Modal.error({
                title,
              })
            }
          }).catch(err => {
            alert('炸了')
          })
        })
      },
    }
  };
</script>
<style lang="less">
  #dataCollection {
    #xmcyz {
      background: yellow !important;

      .ivu-table-tip {
        overflow-x: hidden
      }
    }

    .ivu-input {
      border: none !important;
      text-align: center;
      height: 30px;

      input {
        outline: medium;
      }
    }
  }
</style>